import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 问卷发起记录信息 */
export interface QuestionnaireRecord {
          id: number; // 问卷记录ID
          templateId?: number; // 问卷模板ID
          userId?: number; // 用户ID
          adminUserId?: number; // 医生ID
          title?: string; // 问卷标题
          beginTime?: string | Dayjs; // 问卷开始时间
          endTime?: string | Dayjs; // 问卷结束时间
          durationHour?: number; // 时长（小时）
  }

// 问卷发起记录 API
export const QuestionnaireRecordApi = {
  // 查询问卷发起记录分页
  getQuestionnaireRecordPage: async (params: any) => {
    return await request.get({ url: `/business/questionnaire-record/page`, params })
  },

  // 查询问卷发起记录详情
  getQuestionnaireRecord: async (id: number) => {
    return await request.get({ url: `/business/questionnaire-record/get?id=` + id })
  },

  // 新增问卷发起记录
  createQuestionnaireRecord: async (data: QuestionnaireRecord) => {
    return await request.post({ url: `/business/questionnaire-record/create`, data })
  },

  // 修改问卷发起记录
  updateQuestionnaireRecord: async (data: QuestionnaireRecord) => {
    return await request.put({ url: `/business/questionnaire-record/update`, data })
  },

  // 删除问卷发起记录
  deleteQuestionnaireRecord: async (id: number) => {
    return await request.delete({ url: `/business/questionnaire-record/delete?id=` + id })
  },

  /** 批量删除问卷发起记录 */
  deleteQuestionnaireRecordList: async (ids: number[]) => {
    return await request.delete({ url: `/business/questionnaire-record/delete-list?ids=${ids.join(',')}` })
  },

  // 导出问卷发起记录 Excel
  exportQuestionnaireRecord: async (params) => {
    return await request.download({ url: `/business/questionnaire-record/export-excel`, params })
  },
}